# encoding: utf-8
from flask_marshmallow import base_fields
from app.modules.common.parameters import BaseParameters
from flask_restplus_patched import Parameters


class ApplyRecordListParameters(BaseParameters):
    record_id = base_fields.String(
        description = "申请记录ID",
        required = False,
        missing = None
    )
    plan_id = base_fields.String(
        description = "项目id",
        required = False,
        missing = None
    )
    plan_name = base_fields.String(
        description = "项目名",
        required = False,
        missing = None
    )
    isOnlyoverdue = base_fields.Boolean(
        description = "是否只显示过期申请",
        required = False,
        missing = None
    )
    isOnlyIntegration = base_fields.Boolean(
        description = "是否只显示集成计划申请",
        required = False,
        missing = None
    )
    isOnlyOneMouth = base_fields.Boolean(
        description = "是否只显示一个月内的申请",
        required = False,
        missing = True
    )


class RecordAuditParameters(BaseParameters):
    record_id = base_fields.String(
        description = "申请记录ID",
        required = True,
    )
    level_name = base_fields.String(
        description = "负载级别名称",
        required = True,
    )
    audit_id = base_fields.String(
        description = "审核人ID",
        required = True,
    )
    audit_name = base_fields.String(
        description = "审核人姓名",
        required = True,
    )
    added_desc = base_fields.String(
        description = "审核补充说明",
        required = False,
        missing = None,
    )


class RecordAssignParameters(BaseParameters):
    record_id = base_fields.String(
        description = "申请记录ID",
        required = True,
    )
    agent_ip = base_fields.String(
        description = "分配的ucloud-agent IP",
        required = True,
    )


class RecordAddParameters(BaseParameters):
    plan_id = base_fields.String(
        description = "项目ID",
        required = False,
        missing = None
    )
    plan_name = base_fields.String(
        description = "项目名",
        required = False,
        missing = None
    )
    applicant_id = base_fields.String(
        description = "申请人ID",
        required = True,
    )
    applicant_name = base_fields.String(
        description = "申请人姓名",
        required = True,
    )
    start_date = base_fields.DateTime(
        description = "开始日期",
        required = True,
    )
    expect_recover_date = base_fields.DateTime(
        description = "预计回收日期",
        required = True,
    )
    desc = base_fields.String(
        description = "区域需求/描述",
        required = True,
    )
    type = base_fields.String(
        enum = ['DEV', 'QA', 'UAT'],
        description = "申请环境类型",
        required = True,
    )
    isUseWeb = base_fields.Boolean(
        description = "是否使用外网",
        required = False,
        missing = 'false'
    )
    useWebDesc = base_fields.String(
        description = "使用外网时的描述",
        required = False,
        missing = None
    )
    useOldEnv = base_fields.Boolean(
        description = "使用上一期项目的环境",
        required = False,
        missing = 'false'
    )


class RecordCancelParameters(BaseParameters):
    record_id = base_fields.String(
        description = "申请记录ID",
        required = True,
    )


class RecordCancelForIntegrationParameters(BaseParameters):
    integration_id = base_fields.String(
        description = "集成计划ID",
        required = True,
    )


class UpdateAgentStatusParameters(BaseParameters):
    agent_ip = base_fields.String(
        description = "ucloud ip",
        required = True,
    )


class FreeAgentParameters(BaseParameters):
    plan_name = base_fields.String(
        description = "项目名称",
        required = False,
        missing = None
    )
    apply_id = base_fields.String(
        description = "申请记录id",
        required = False,
        missing = None
    )


class RemoveRecordParameters(BaseParameters):
    plan_id = base_fields.String(
        description = "项目id",
        required = True,
    )
    env_type = base_fields.String(
        enum = ['DEV', 'QA', 'UAT'],
        description = "环境类型",
        missing = None,
        required = False,
    )


class RecordAddIntegrationApplyParameters(BaseParameters):
    integration_id = base_fields.String(
        description = "集成计划ID",
        required = True,
    )
    integration_name = base_fields.String(
        description = "集成计划名",
        required = True,
    )
    start_date = base_fields.DateTime(
        description = "开始日期",
        required = True,
    )
    expect_recover_date = base_fields.DateTime(
        description = "预计回收日期",
        required = True,
    )


class KeepParameters(BaseParameters):
    plan_id = base_fields.String(
        description = "项目id",
        required = False,
        missing = None
    )
    agent_ip = base_fields.String(
        description = "机器ip",
        missing = None,
        required = False,
    )
    apply_id = base_fields.String(
        description = "申请记录id",
        missing = None,
        required = False,
    )


class UpdateApplyEndTimeParameters(Parameters):
    plan_id = base_fields.String(
        description = "项目id",
        required = True
    )
    to_date = base_fields.Date(
        description = "新回收时间",
        required = True
    )


class PlanNotifyParameters(Parameters):
    day = base_fields.Integer(
        description = "天数",
        required = True
    )
